package org.onion.pattern.event.springboot.rocketmq.config;


import org.onion.pattern.event.springboot.rocketmq.annotation.RocketMQConsumerGroup;

import java.util.Map;

public class ConsumerPropertiesFactory {

    RocketMQEventProperties rocketMQEventConfig;

    public ConsumerPropertiesFactory(RocketMQEventProperties rocketMQEventConfig) {
        this.rocketMQEventConfig = rocketMQEventConfig;
    }

    public RocketMQEventProperties.ConsumerProperties create(String dynamicKey, RocketMQConsumerGroup anno, Class<?> eventListenerType) {
        final RocketMQEventProperties.CommonConsumerProperties commonConsumerProperties = rocketMQEventConfig.getConsumer();
        final Map<String, RocketMQEventProperties.ConsumerProperties> dynamicConsumerProperties = rocketMQEventConfig.getDynamic().getDynamicConsumer();
//        if (StringUtils.isEmpty(commonConsumerProperties.getNamespace())) {
//            commonConsumerProperties.setNamespace(rocketMQEventConfig.getDefaultNamespace());
//        }
//        if (StringUtils.isEmpty(commonConsumerProperties.getNameServer())) {
//            commonConsumerProperties.setNameServer(rocketMQEventConfig.getDefaultNameServer());
//        }
//        RocketMQEventProperties.ConsumerProperties consumerProperties = dynamicConsumerProperties.getOrDefault(dynamicKey, new RocketMQEventProperties.ConsumerProperties());
//        if (StringUtils.isEmpty(consumerProperties.getNamespace())) {
//            consumerProperties.setNamespace(commonConsumerProperties.getNamespace());
//        }
//        if (StringUtils.isEmpty(consumerProperties.getNameServer())) {
//            consumerProperties.setNameServer(commonConsumerProperties.getNameServer());
//        }
//        if (Objects.isNull(consumerProperties.getConsumeThreadMax())) {
//            consumerProperties.setConsumeThreadMax(commonConsumerProperties.getConsumeThreadMax());
//        }

//        if (Objects.isNull(consumerProperties.getCodec())) {
//            consumerProperties.setCodec(commonConsumerProperties.getCodec());
//        }

//        if (StringUtils.isEmpty(consumerProperties.getNamespace())) {
//            consumerProperties.setNamespace(anno.namespace());
//        }
//        if (StringUtils.isEmpty(consumerProperties.getNameServer())) {
//            consumerProperties.setNameServer(anno.nameServer());
//        }
//        if (StringUtils.isEmpty(consumerProperties.getGroup())) {
//            consumerProperties.setGroup(anno.value());
//        }
//        if (Objects.isNull(consumerProperties.getConsumeThreadMax())) {
//            consumerProperties.setConsumeThreadMax(anno.consumeThreadMax());
//        }
//
//        if (StringUtils.isEmpty(consumerProperties.getGroup())) {
//            consumerProperties.setGroup(eventListenerType.getName().replace(".", "-").replace("$", "-"));
//        }
//        return consumerProperties;
        return null;


    }
}
